﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Pawn
{
    public partial class FrmGiaHan : Form
    {
        public DateTime HanCu { get; set; }
        public DateTime HanMoi { get { return dpGiaHan.Value; } }
        bool xuly=false;
        public FrmGiaHan()
        {
            InitializeComponent();
        }

        private void FrmGiaHan_Load(object sender, EventArgs e)
        {

            dpGiaHan.Value = ((DateTime)HanCu).AddDays(10);
     
        }

        private void tbGiaHan_ValueChanged(object sender, EventArgs e)
        {
            if (xuly) return;
            xuly = true;
            tbGiaHan.Value = (dpGiaHan.Value - (DateTime)HanCu).Days;
            xuly = false;
        }

        private void udGiaHan_ValueChanged(object sender, EventArgs e)
        {
            if (xuly) return;
            xuly = true;
            dpGiaHan.Value = ((DateTime)HanCu).AddDays((int)tbGiaHan.Value);
            xuly = false;
        }

        private void btnXacNhan_Click(object sender, EventArgs e)
        {
            //if (tbGiaHan.Value < 10)
            //{
            //    MessageBox.Show("Số ngày gia hạn phải >= 10 ngày!");
            //    return;
            //}

            DialogResult = DialogResult.OK;
            this.Close();
        }

        private void btnHuy_Click(object sender, EventArgs e)
        {
            this.Close();
        }

    }
}
